package hikari.managers;

import com.gooddies.wiring.annotations.Wire;
import com.gooddies.wiring.annotations.WiringComponent;
import hikari.gui.MainWindow;
import hikari.preferences.GameProperties;
import hikari.utils.Utils;
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;

/**
 * @author sad
 */
@WiringComponent(singleton = true, lazy = true)
public class RunManager {

    @Wire
    private GameProperties gameProperties;
    @Wire
    private MainWindow mainWindow;
    @Wire
    private Utils utils;
    

    private RunManager() {
    }

    public void runScene() {
        if (!gameProperties.isProjectSaved()) {
            utils.errorMessage("Please save the project");
            return;
        }

        if (!mainWindow.isSceneSaved()) {
            utils.errorMessage("Please save the scene");
            return;
        }
        String sceneName = mainWindow.getCurrentSceneName();
        String baseFolder = gameProperties.getBaseFolder();
        try {
            FileUtils.writeStringToFile(new File(utils.combinePaths(baseFolder, "scene.dbg")), sceneName);
        } catch (IOException ex) {
            utils.logError(ex);
            utils.errorMessage("Error while write file scene.dbg");
        }

    }

    public void runGame() {
        utils.errorMessage("Function is not implemented now");
    }
}
